package com.qf.ssm.service.Impl;

import com.qf.ssm.entity.PropertyManage;
import com.qf.ssm.ex.ServiceException;
import com.qf.ssm.mapper.PropertyManageMapper;
import com.qf.ssm.service.PropertyManageService;
import com.qf.ssm.utils.ResponseCode;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PropertyManageServiceImpl implements PropertyManageService {
    @Resource
    PropertyManageMapper propertyManageMapper;

    @Override
    public List<PropertyManage> selectAs(String pmType, String as) {
        try {
            return propertyManageMapper.selectAs(pmType, as);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.PROPERTY_SELECT);
        }
    }

    @Override
    public List<PropertyManage> selectName(String pmType, String pmName) {
        try {
            return propertyManageMapper.selectName(pmType, pmName);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.PROPERTY_SELECT);
        }
    }

    @Override
    public List<PropertyManage> selectGroup(String pmType, int pgID) {
        try {
            return propertyManageMapper.selectGroup(pmType, pgID);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.PROPERTY_SELECT);
        }
    }

    @Override
    public int update(PropertyManage propertyManage) {
        try {
            return propertyManageMapper.update(propertyManage);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.PROPERTY_EDIT);
        }
    }

    @Override
    public List<PropertyManage> selectDefaultDisplay() {
        try {
            return propertyManageMapper.selectDefaultDisplay();
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.PROPERTY_SELECT);
        }
    }

    @Override
    public int insert(PropertyManage propertyManage) {
        try {
            return propertyManageMapper.insert(propertyManage);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.PROPERTY_NEW);
        }
    }

    @Override
    public int delete(Integer pmId) {
        try {
            return propertyManageMapper.delete(pmId);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.PROPERTY_DELETE);
        }
    }

    @Override
    public int disable(Integer pmId) {
        try {
            return propertyManageMapper.disable(pmId);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.PROPERTY_DISABLE);
        }
    }

    @Override
    public int enable(Integer pmId) {
        try {
            return propertyManageMapper.enable(pmId);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.PROPERTY_ENABLE);
        }
    }

    @Override
    public int batchDelete(int[] pmIds) {
        try {
            return propertyManageMapper.batchDelete(pmIds);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.PROPERTY_BATCH_DELETE);
        }
    }

    @Override
    public PropertyManage selectPropertyAndGroup(int pmId) {
        try {
            return propertyManageMapper.selectPropertyAndGroup(pmId);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.PROPERTY_SELECT);
        }
    }

    @Override
    public int batchDeleteList(List<Integer> pmIds) {
        try {
            return propertyManageMapper.batchDeleteList(pmIds);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.PROPERTY_BATCH_DELETE);
        }
    }

    @Override
    public int batchInsert(List<PropertyManage> propertyManages) {
            return propertyManageMapper.batchInsert(propertyManages);

    }

    @Override
    public int batchInsertList(List<PropertyManage> propertyManages) {

            return propertyManageMapper.batchInsertList(propertyManages);

    }
}
